package com.ai.controller.made;


import com.ai.annotation.EnterPathParamLog;
import com.ai.common.CommonResponse;
import com.ai.entity.made.page.OpcNodeInfoPage;
import com.ai.entity.made.page.OpcServerInfoPage;
import com.ai.model.dto.OpcNodeInfoDto;
import com.ai.model.dto.OpcServerInfoDto;
import com.ai.service.made.IOpcNodeInfoService;
import com.ai.service.made.IOpcServerInfoService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * opc 节点
 * @author jiaok
 * @since 2024-11-14
 */
@RestController
@RequestMapping("/opc-node-info")
public class OpcNodeInfoController {


    @Resource
    private IOpcNodeInfoService iOpcNodeInfoService;

    @ApiOperation("新增opc节点")
    @PostMapping("add")
    @EnterPathParamLog
    public CommonResponse<String> add(@RequestBody OpcNodeInfoDto opcNodeInfoDto){
        return iOpcNodeInfoService.add(opcNodeInfoDto);
    }

    @ApiOperation("删除opc节点")
    @PostMapping("delete/{id}")
    @EnterPathParamLog
    public CommonResponse<String> delete(@PathVariable(value = "id") String opcDeviceId){
        return iOpcNodeInfoService.delete(opcDeviceId);
    }

    @ApiOperation("修改opc节点")
    @PostMapping("edit")
    @EnterPathParamLog
    public CommonResponse<String> edit(@RequestBody OpcNodeInfoDto opcNodeInfoDto){
        return iOpcNodeInfoService.edit(opcNodeInfoDto);
    }

    @ApiOperation("opc设备节点分页")
    @PostMapping("pageList")
    @EnterPathParamLog
    public IPage selectByPage(@RequestBody OpcNodeInfoPage page) {
        return   iOpcNodeInfoService.selectByPage(page);
    }

    @ApiOperation("获取指定指定设备类型的server下的所有node节点")
    @PostMapping("getOpcNodeNameList/{deviceServerId}/{deviceType}")
    @EnterPathParamLog
    public CommonResponse getOpcNodeNameList(@PathVariable(value = "deviceServerId") String deviceServerId,@PathVariable(value = "deviceType") String deviceType){
        return iOpcNodeInfoService.getOpcNodeNameList(deviceServerId,deviceType);
    }

    @ApiOperation("获取指定opcServer下的所有node节点")
    @PostMapping("getOpcNodeNameList/{opcServerId}")
    @EnterPathParamLog
    public CommonResponse getOpcNodeNameList(@PathVariable(value = "opcServerId") String opcServerId){
        return iOpcNodeInfoService.getOpcNodeNameList(opcServerId);
    }


}
